 
 #include <iostream>
 
 
void cat(float *a, int s1, int m1, float *b, int s2, int m2, int dim, float *arr){
    int s = s1 + s2;
        if (dim == 1){
            int tag = 0;
            int i = 0,j = 0, k = 0;
            while (i < s)
            {
                if (tag == 0){
                    arr[i] = a[j];
                    j++;
                    if(j % m1 == 0){
                        tag = 1;
                    }
                }else{
                    arr[i] = b[k];
                    k++;
                    if(k % m2 == 0){
                        tag = 0;
                    }
                }
                i++;
            }  
        }else if (dim == 0){
            int i = 0,j = 0;
            while (i < s){
                if (i < s1){
                    arr[i] = a[i];
                }else{
                    arr[i] = b[j];
                    j++;
                }
                
                i++;
            }
        }
}

int main(){
    
    
    float a[2*3] = {1,2,3,4,5,6};
    float b[2*2] = {11,12,13,14};
    float arr[12];
    cat(a,6,3,b,4,2,1,arr);

    // for (int i = 0; i < 12; i++) {
    //     std::cout << arr[i] << " ";
    // }

    for (int i = 0; i < 2; i++) {
        for(int j = 0; j < 5; j++){
            std::cout << arr[i * 5 + j] << " ";
        }
        std::cout << std::endl;
    }
}
